package br.com.webcrm.service.impl;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import br.com.webcrm.dao.ViewEventoDAO;
import br.com.webcrm.model.ViewEvento;
import br.com.webcrm.service.ViewEventoService;

@Service(value = "viewEventoService")
public class ViewEventoServiceImpl extends BaseServiceImpl implements
		ViewEventoService {

	@Resource
	private ViewEventoDAO viewEventoDAO;
	private List<ViewEvento> listaEventos = new ArrayList<ViewEvento>();

	public ViewEventoDAO getViewEventoDAO() {
		return viewEventoDAO;
	}

	public void setViewEventoDao(ViewEventoDAO viewEventoDAO) {
		this.viewEventoDAO = viewEventoDAO;
	}

	@Override
	@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Throwable.class, propagation = Propagation.REQUIRED)
	public List<ViewEvento> consultarPorDataOrigem(Date dataInicial,
			Date dataFinal, Integer iddestino, String tipo_destino,
			Boolean apenasNaoFinalizados) {
		listaEventos = getViewEventoDAO().consultarPorDataOrigem(dataInicial,
				dataFinal, iddestino, tipo_destino, apenasNaoFinalizados);		
		return listaEventos;
	}

	@Override
	@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Throwable.class, propagation = Propagation.REQUIRED)
	public List<ViewEvento> consultarPorDataPrevista(Date dataInicial,
			Date dataFinal, Integer iddestino, Integer grupoDestino,
			Boolean apenasNaoFinalizados) {
		listaEventos = getViewEventoDAO().consultarPorDataPrevista(dataInicial,
				dataFinal, iddestino, grupoDestino , apenasNaoFinalizados);		
		return listaEventos;
	}

	@Override
	@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED, rollbackFor = Throwable.class, propagation = Propagation.REQUIRED)
	public List<ViewEvento> consultarEventosPorIdCliente(Integer idCliente)
			throws Exception {
		
		return getViewEventoDAO().consultarEventosPorIdCliente(idCliente);
	}	
}
